home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 19
/
Mac Magazin and MacEasy Magazine CD - Issue 19.iso
/
Online
/
LineShare 3.3.1
/
LineShare Scripts
/
Fax Class2.0&ARA&Data
< prev
next >
Wrap
Text File
|
1995-11-11
|
8KB
|
431 lines
! Version 3.3
!
!$ Use this script with Class 2.0 fax software, ARA 1.0 or 2.0,
!$ and a BBS, E-mail or other communication server software
!
!$ Make sure that your modem and fax software support Class 2.0
!$ (US Robotics modems, CommuniGate FaxGate)
^# Modem:
^3 Error Correction: = Bool("Enabled"="AUTO","Disabled"="NORM") "NORM"
^4 Handshake wires: = Bool("CTS+DTR"="&D0","CTS only"="&D2") "&D2"
^5 Answer On: = Enum("Never"="0","1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
^6 Data Port Speed: = Enum("9600","19200","38400","57600") "19200"
! ------------------------------------------
! Resetting the modem:
! ------------------------------------------
@Hangup
SetFCLASS "0,1,2.0"
SetTries 2
Flush
HsReset 0,0,0,0,0,0
DtrSet
!
! Try to catch the "OK" answer, use the Escape seq and DTR transitions
! to enter the command mode
!
@Label 1
matchclr
matchstr 1 2 "OK\r\n"
write "ATH0V1Q0E1\r"
matchread 20
ChrDelay 1
Write "+++"
ChrDelay 0
DtrClear
SBreak
DtrSet
!
DecTries
IfTries 0 1
!
! OSErr -6019 "Modem error - the modem is not responding"
!
exit -6019
@Label 2
SetVar A "&F"
GetOption A "DFLT" 3
@Label 3
write "AT^A+FCLASS=0\r"
Jsr 100
exit 0
@Label 6
Say "This script cannot be used with this modem"
ifOriginate 7
pause 1800
@Label 7
exit -6019
! ------------------------------------------
! Receiving incoming calls
! ------------------------------------------
@ANSWER
@Label 10
!
! Set the modem preferred speed first
SerReset Val("^6"),0,8,1
Jsr 80
!
! Set the common options
Jsr 70
!
! Set the communication options:
! • Normal/AUTO Connection
! • HW flow control (for ARA, Fax should not use a handshake on receiving)
! • CONNECT <DCE speed> or CARRIER/CONNECT
!
GetOption A "HWHS" 6
GetOption B "^3" 6
GetOption C "LNRS" 6
Write "AT^A^B^C\r"
Jsr 100
!
! Set Fax parameters: LID, DCC,BOR
!
Write "AT+FCLASS=2.0\r"
Jsr 100
Write "AT+FCR=1;+FAA=1;+FLO=2;+FNR=1,1,1\r"
Jsr 100
!
! Set FLID - sometimes it can fail
!
GetCommand A "Fax" "+FLI"
Write "AT^A\r"
Jsr 100
Write "AT+FCC=1,5,0,2,0,0,0,0\r"
Jsr 100
!
! Set FCC - sometimes it can fail
!
GetCommand A "Fax" "+FCC"
Write "AT^A\r"
Jsr 100
GetCommand A "Fax" "+FBO"
Write "AT^A\r"
Jsr 100
!
! Get the Speaker options
GetCommand B "Fax" "M"
GetCommand C "Fax" "L"
!@Label 13
SetVar A "S0=^5"
!
! Answer call after <A> rings
Write "AT^A^B^C\r"
Jsr 100
!
! Everything is ready - let's sit and wait for a call
! We'll wait for 2 minutes, then reinitiate the modem
Note "Waiting for a Fax/ARA/Data call…"
Jsr 90
IfStr D 40 "FAX"
IfStr D 20 "DATA"
Jump 10
!
! Data connection has been established (we read "CONNECT")
! Put the "CONNECT" back to the buffer and attach the "Data" subPort
! if it was an incoming call, put the "RING" before the "CONNECT"
!
@Label 20
IfOpen "Data" 21
Jump 30
@Label 21
IfOpen "ARA" 22
Jump 35
@Label 22
Note "Waiting for an ARA frame"
MatchClr
MatchStr 1 23 "^$\r"
MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
MatchStr 3 29 "\01\27\02\29\01\02\01\06"
MatchRead 40
Jump 24
@Label 23
QueueInput "^$\r"
@Label 24
Note "Non-ARA call"
Jump 35
@Label 28
Note "ARA 1.0 call"
Jump 30
@Label 29
Note "ARA 2.0 call"
Jump 30
@Label 30
QueueInput "\r\nCARRIER ^B\r\n"
IfStr A 31 "NONE"
IfStr A 31 "None"
QueueInput "\r\nREL\r\n"
@Label 31
IfOriginate 32
QueueInput "\r\nRING\r\n"
@Label 32
Attach "ARA" (DTR)
@Label 35
GetSReg C "DATA" 4
QueueInput "\r^CCONNECT ^B\r^C"
ifOriginate 36
QueueInput "\r^CRING\r^C"
@Label 36
HsReset 0,1,0,0,0,1
Attach "Data" (DTR,Escape,Break)
!
! Fax connection has been established (we read "+FCON")
! Put the +FCON back to the buffer,
! if it was an incoming call, put the "RING" before the "+FCON"
! Attach the "Fax" subPort
!
@Label 40
QueueInput "\r\n+FCO"
ifOriginate 41
QueueInput "\r\nRING\r\n"
@Label 41
Attach "Fax" (DTR,Reset,IdleLimit=30)
! ------------------------------------------
! Originating a call through the "ARA" subport
! ------------------------------------------
@ORIGINATE "ARA"
SerReset Val("^6"),0,8,1
Jsr 80
!
! Set the common options
Jsr 70
Jsr 60
!
! Set the communication options:
! • Normal Connection
! • HW flow control
! • CONNECT <DCE speed> or CARRIER/CONNECT
!
GetOption A "HWHS" 6
GetOption B "^3" 6
GetOption C "LNRS" 6
Write "AT^A^B^C\r"
Jsr 100
!
! dial the number
Write "ATD^1\r"
!
! Wait for a modem response
Jsr 92
IfStr D 30 "DATA"
Write "\r"
Exit -6019
! ------------------------------------------
! Originating a call through the "DATA" subport
! ------------------------------------------
@ORIGINATE "Data" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
SerReset Val("^6"),0,8,1
Jsr 80
!
! Set the common options
Jsr 70
!
! Set the communication options:
! • Normal Connection
! • HW flow control
! • CONNECT <DCE speed> or CARRIER/CONNECT
!
GetOption A "HWHS" 6
GetOption B "^3" 6
GetOption C "LNRS" 6
Write "AT^A^B^C\r"
Jsr 100
!
! dial the number
Write "ATD^1\r"
HsReset *
!
! Wait for a modem response
Jsr 92
IfStr D 35 "DATA"
Write "\r"
Exit -6019
! ------------------------------------------
! Originating a call through the "Fax" subPort
! ------------------------------------------
@ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
!
! Set the "Fax" speed
!
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
!
Jsr 70
!
! Now emit all commands that the application has sent to that port,
! except "V" and "+FCLASS"
!
EmitClear "V","+FCLASS"
Jsr 60
Write "AT+FCLASS=2.0\r"
Jsr 100
HsReset *
!
! dialing the number
Write "ATD^1\r"
Jsr 90
IfStr D 40 "FAX"
Write "\r"
Exit -6019
!
! This section emits all modem commands sent from the client application
! For each set of commands the "OK" answer is awaited
!
@Label 60
EmitStart
@Label 61
EmitCommand 62
Jsr 100
Jump 61
@Label 62
return
!
! This section initiates the modem before ANSWER and ORIGINATEs:
! reset on Dtr drop + DCD valid
! Verbal responses mode, no echo
!
@Label 70
Write "AT^4&C1V1E0\r"
Jsr 100
return
!
! This section syncronize the modem after the serial port speed switching
!
@Label 80
ChrDelay 1
Write "AT\r"
ChrDelay 0
Jsr 100
return
!
! Error codes
@Label 81
exit -6020
@Label 82
exit -6022
@Label 83
exit -6021
@Label 84
exit -6023
@Label 85
Note "Data Call"
Jump 92
!
! Processing CONNECT message:
! If the speed has not been set to ^B with a CARRIER message, take
! the speed from the CONNECT message
!
@Label 86
ifStr B 87 ""
return
@Label 87
SetVar B "^$"
return
!
! This subroutine waits for the modem response
! On exit, ^D contains the result code: "FAX" or "DATA"
! ^A contains the protocol used
! ^B contains the carrier speed
! If modem reports an error, the scripts exits with an error code
!
!
! Fax connection was established
!
@Label 88
SetVar D "FAX"
return
@Label 89
Note "Ring…"
Jump 91
@Label 90
SetVar A "NONE"
SetVar B ""
MatchClr
Matchstr 1 88 "+FCO"
Matchstr 2 92 "+FDM"
Matchstr 6 89 "RING\r\n"
Matchstr 10 82 "BUSY\r\n"
MatchStr 11 83 "NO CARRIER\r\n"
MatchStr 12 84 "NO ANSWER\r\n"
MatchStr 13 81 "NO DIALTONE\r\n"
@Label 91
Matchread 1200
SetVar D "NONE"
return
@Label 92
SetVar A "NONE"
SetVar B ""
MatchClr
Matchstr 1 94 "CARRIER ^$\r\n"
Matchstr 2 95 "PROTOCOL: ^$\r\n"
Matchstr 4 96 "CONNECT ^$/"
Matchstr 5 98 "CONNECT ^$\r\n"
Matchstr 10 82 "BUSY\r\n"
MatchStr 11 83 "NO CARRIER\r\n"
MatchStr 12 84 "NO ANSWER\r\n"
@Label 93
Matchread 1200
SetVar D "NONE"
return
@Label 94
SetVar B "^$"
Jump 93
@Label 95
SetVar A "^$"
Jump 91
! CONNECT xxxx/XXXX was detected
@Label 96
Jsr 86
MatchClr
MatchStr 1 97 "^$\r\n"
MatchRead 10
@Label 97
SetVar A "^$"
SetVar D "DATA"
return
! CONNECT xxx was detected
@Label 98
Jsr 86
SetVar D "DATA"
return
!
! Processing the AT command:
! OK -> proceed
! ERROR or TimeOut ->exit -6019
! It can be called AFTER the "Write" command, since LineShare buffers input
!
@Label 100
MatchClr
MatchStr 1 102 "OK\r\n"
MatchStr 2 101 "ERROR\r\n"
MatchRead 20
@Label 101
Exit -6019
@Label 102
return